package com.dense.kuiniu.floatcabinet.mvp.ui.adapter;

import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.dense.kuiniu.floatcabinet.R;
import com.dense.kuiniu.floatcabinet.mvp.http.entity.Book;

import org.jetbrains.annotations.NotNull;

import javax.inject.Inject;

/**
 * @author Administrator
 * @date 2020/11/2
 */
public class BookQueryAdapter extends BaseQuickAdapter<Book, BaseViewHolder> {
    @Inject
    public BookQueryAdapter(int layoutResId) {
        super(layoutResId);
    }

    @Override
    protected void convert(@NotNull BaseViewHolder baseViewHolder, Book book) {
        baseViewHolder.setText(R.id.tv_name, "《"+book.getBookName()+"》");
        baseViewHolder.setText(R.id.tv_author_value, book.getAuthor());
        baseViewHolder.setText(R.id.tv_press_value, book.getFkPressName());
        baseViewHolder.setText(R.id.tv_location_value, book.getDoorNumber() + "号门");
        ImageView cover = baseViewHolder.findView(R.id.iv_image);
        if (cover != null) {
            Glide.with(getContext())
                    .load(book.getCoverPhotoUrl())
                    .centerCrop()
                    .error(R.mipmap.bg_default_cover)
                    .placeholder(R.mipmap.bg_default_cover)
                    .into(cover);
        }
    }
}